import Mock from 'mockjs'

const menus = [
  {
    id: 1,
    title: '系统管理',
    name: 'sys',
    view: 'main/index',
    type: 'menu',
    icon: 'md-cog',
    status: 1,
    createTime: Mock.mock('@datetime'),
    updateTime: Mock.mock('@datetime'),
    createBy: '@cname',
    updateBy: '@cname',
    path: '/sys',
    children: [
      {
        id: 11,
        title: '用户管理',
        name: 'sys.user',
        view: 'sys/user',
        path: 'user',
        type: 'menu',
        icon: 'md-person',
        status: 1,
        createTime: Mock.mock('@datetime'),
        updateTime: Mock.mock('@datetime'),
        createBy: '@cname',
        updateBy: '@cname'
      },
      {
        id: 12,
        title: '角色管理',
        name: 'sys.role',
        view: 'sys/role',
        path: 'role',
        type: 'menu',
        icon: 'md-person-add',
        status: 1,
        createTime: Mock.mock('@datetime'),
        updateTime: Mock.mock('@datetime'),
        createBy: '@cname',
        updateBy: '@cname'
      },
      {
        id: 13,
        title: '菜单管理',
        name: 'sys.menu',
        view: 'sys/menu',
        path: 'menu',
        type: 'menu',
        icon: 'md-menu',
        status: 1,
        createTime: Mock.mock('@datetime'),
        updateTime: Mock.mock('@datetime'),
        createBy: '@cname',
        updateBy: '@cname'
      }
    ]
  },
  {
    id: 2,
    title: '工具管理',
    name: 'tool',
    view: 'main/index',
    path: '/tool',
    icon: 'md-hammer',
    status: 1,
    createTime: Mock.mock('@datetime'),
    updateTime: Mock.mock('@datetime'),
    createBy: '@cname',
    updateBy: '@cname',
    children: [
      {
        id: 21,
        title: '内容管理',
        name: 'tool.home',
        view: 'tool/home',
        path: 'home'
      },
      {
        id: 22,
        title: '圈子管理',
        name: 'tool.circle',
        view: 'tool/circle',
        path: 'circle'
      },
      {
        id: 23,
        title: '活动管理',
        name: 'tool.activity',
        view: 'tool/activity',
        path: 'activity'
      }
    ]
  }
]
Mock.mock(/\/api\/sys\/menus/, 'get', {
  code: 200,
  data: menus
})

Mock.mock(/\/api\/sys\/menu\/update/, 'post', {
  code: 200,
  data: { id: '@id' }
})

Mock.mock(/\/api\/auth\/token/, 'post', {
  code: 200,
  data: {
    token: '@id'
  }
})

Mock.mock(/\/api\/user\/info/, 'get', {
  code: 200,
  data: {
    id: '@id',
    name: '@cname',
    email: '@email',
    avatar: '@data:image'
  }
})
